/**
 * Created by bell on 2017/7/31.
 */

import ARect from './ARect'
import AViewController from '../ViewController/AViewController'
import dispatch from '../Util/dispatch'

export default class AWindow {

    constructor() {
        this._rootViewController = null
        window.onresize = ()=> {
            if(this.onresize) {
                this.onresize()
            }
        }
    }

    get bounds() : ARect {
        return new ARect(0, 0, window.innerWidth, window.innerHeight)
    }

    show() {
        dispatch.async(() => {
            if(this._rootViewController) {
                this._rootViewController.update()
            }
        })
    }

    set rootViewController(viewController : AViewController) {
        this._rootViewController = viewController
        viewController.window = this
    }
}
